home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows 95 API Bible
/
Windows 95 API Bible 3 Disc Set.iso
/
Win32 API Bible Book 1 of 3
/
CHAPTE18
/
EX3.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-12-27
|
3KB
|
81 lines
#include <genstub.c>
LRESULT CALLBACK WndProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) /* process windows messages */
{
case WM_PAINT:
{
HWND hCBOwner; /* handle to owner of clipboard */
HWND hCBViewer; /* handle of first viewer of clipboard */
HWND hCBOpenWnd; /* handle of window with clipboard open */
char cBuf [128]; /* TextOut buffer work area */
char cName [64]; /* name of window work area */
PAINTSTRUCT ps;
BeginPaint( hWnd, &ps ); /* Erase the background, Fill in the ps structure */
OpenClipboard(hWnd);
EmptyClipboard();
SetClipboardData(CF_TEXT, 0);
CloseClipboard();
hCBOwner = GetClipboardOwner( ); /* return the owner of the clipboard */
if (hCBOwner == NULL)
lstrcpy( cName, "<None>" ) ;
else
GetWindowText( hCBOwner, cName, 63 );
/* show who is the owner of the clipboard */
TextOut( ps.hdc, 10, 10, cBuf,
wsprintf( cBuf, "Clipboard Owner: %s", (LPSTR) cName ) );
hCBViewer = GetClipboardViewer( ); /* return the first viewer of the clipboard */
if (hCBViewer == NULL)
lstrcpy( cName, "<None>" ) ;
else
GetWindowText( hCBViewer, cName, 63 );
TextOut ( ps.hdc, 10, 30, cBuf, wsprintf ( cBuf,
"Clipboard Viewer: %s", (LPSTR) cName ) ) ;
/* return the window that last opened the clipboard */
hCBOpenWnd = GetOpenClipboardWindow( );
if (hCBOpenWnd == NULL)
lstrcpy( cName, "<None>" );
else
GetWindowText( hCBOpenWnd, cName, 63 );
TextOut( ps.hdc, 10, 50, cBuf, wsprintf (cBuf,
"Opened Clipboard: %s", (LPSTR) cName) );
EndPaint( hWnd, &ps ) ; /* validate the rectangle - stop painting */
}
break ;
case WM_CHANGECBCHAIN: /* change in clipboard viewer chain */
InvalidateRect(hWnd, NULL, TRUE); // force paint and refresh
break;
case WM_COMMAND:
switch (wParam)
{
case IDM_TEST:
InvalidateRect( hWnd, NULL, TRUE ); /* provoke a paint to print report */
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
#include <aboutopt.c>
}
break;
#include <rbutton.c>
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
return (0L);
}
#include <about.c>